<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  .box {
    width: 600px;
    height: 200px;
    background-color: pink;
    margin: 100px auto;
    font-size: 50px;
    text-align: center;
    line-height: 200px;
  }

  .x {
    float: right;
    width: 20px;
    height: 20px;
    font-size: 20px;
    text-align: center;
    line-height: 20px;
    background-color: rgba(0, 0, 0, 0.4);
    color: white;
    cursor: pointer;
  }
</style>

<body>
  <div class="box">
    我是一个大广告
    <div class="x">x</div>
  </div>
  <script>
    // const box = document.querySelector('.box')
    const x = document.querySelector('.x')
    x.addEventListener('click', function () {
      x.parentNode.style.display = 'none'
    })
  </script>
</body>

</html>